﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class UserControls_SiteMapLoaiSanPham : System.Web.UI.UserControl
{
    private string _url;
    private int mapl  = -1;
    public int Mapl
    {
        get { return mapl; }
        set { mapl = value; }
    }
    public string Url
    {
        get { return _url; }
        set { _url = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request["MaPL"] == null && mapl == -1)
        {
            this.Visible = false;
            return;
        }
        string str = "";
        if(mapl == -1)
            mapl = int.Parse(Request["MaPL"].ToString());
        DataDSTableAdapters.PHANLOAITableAdapter plAdapter = new DataDSTableAdapters.PHANLOAITableAdapter();
        DataDS.PHANLOAIDataTable plTable = new DataDS.PHANLOAIDataTable();
        plTable = plAdapter.PHANLOAI_LayTheoId(mapl);
        str = "<span>"+plTable[0].TenPhanLoai+"</span>";
        while(true)
        {
            plTable = plAdapter.PHANLOAI_LayPLCha(mapl);
            if (plTable.Rows.Count > 0)
            {
                str = str.Insert(0, "<a href='" + _url + "?MaPL=" + plTable[0].Id + "'>" + plTable[0].TenPhanLoai + "</a> > ");
                mapl = plTable[0].Id;
            }
            else
                break;
        }
        str = str.Insert(0, "<a href='/SMO/Index.aspx'>Tất cả</a> > ");
        
        lbSiteMap.Text = str;      
        
    }
}
